<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/jquery.js"></script>
    <script>
        function generateNum() {
            var p = new Promise(function(resolve, reject) {
                setTimeout(function() {
                    var num = Math.random()
                    resolve(num);
                }, 2000)
            })
            return p
        }

        $(function() {
                $('button').click(async function() {
                    // generateNum().then(function(data) {
                    //     console.log(data);
                    // })
                    var n = await generateNum()
                    console.log(n);

                })
            })
            // 点击按钮调用generateNum, 这个函数内部会在2s后产生一个随机数值, 如何在点击处理函数中使用两种方式得到这个随机值
    </script>
</head>

<body>
    <button>点我试试</button>
</body>

</html>